//
// Created by fei on 9/9/17.
// Copyright (c) 2017 fei. All rights reserved.
//

import UIKit

class MainViewController:UITabBarController {
    override func viewDidLoad() {
        super.viewDidLoad()





//        var mainTabBar = MainTabBar()

//        print("mayuyu is a kawaii girl!!")

//    setValue(mainTabBar, forKey: "tabBar")

        addChildViewControllers()


        //classForCoder 打印函数的类名
        print(tabBar.classForCoder)
        //设置点击事件
//        mainTabBar.composeBtn.addTarget(self, action: #selector(MainViewController.composeDidClick), for: .touchUpInside)




    }

    fileprivate func addChildViewControllers() {

        addChildViewController(vc: HomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(vc:DiscoverViewController(), title: "投资", imageName: "tabbar_message_center")
        addChildViewController(vc:MessageViewController(), title: "朵朵来电", imageName: "tabbar_discover")
        addChildViewController(vc:ProfileViewController(), title: "账户", imageName: "tabbar_profile")


    }

    fileprivate func addChildViewController(vc: UIViewController,title:String,imageName:String) {


//        vc.tabBarItem.
    self.tabBar.tintColor = .orange
        let nav = UINavigationController(rootViewController: vc)


        nav.title = title
        vc.navigationItem.title = title

//        nav.navigationBar

        nav.tabBarItem.image = UIImage(named: imageName)

        addChildViewController(nav)


    }


    @objc fileprivate func composeDidClick() {
        print(#function)
    }

}
